package com.nsl.my_youlai.Jackson.online;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.junit.jupiter.api.Test;

public class Demo1 {

    @Test
    public void test1() throws JsonProcessingException {
        String json="{\n" +
                "    \"id\": 1,\n" +
                "    \"itemName\": \"theItem\",\n" +
                "    \"owner\": {\n" +
                "        \"id\": 2,\n" +
                "        \"name\": \"theUser\"\n" +
                "    }\n" +
                "}";

        ObjectMapper mapper = new ObjectMapper();
        SimpleModule module = new SimpleModule();
        module.addDeserializer(Item.class, new ItemDeserializer());
        mapper.registerModule(module);

        Item readValue = mapper.readValue(json, Item.class);
        System.out.println(readValue);
    }


}
